package com.example.messagemodule.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

@SuppressLint("AppCompatCustomView")
public class MessageTextLeft extends TextView {
    public MessageTextLeft(Context context) {
        super(context);
    }

    public MessageTextLeft(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MessageTextLeft(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.WHITE);
        paint.setStrokeWidth(5);
        paint.setStyle(Paint.Style.FILL);

        int width = getWidth();
        int height = getHeight();

        Path path = new Path();
        path.moveTo(15, 20);
        path.lineTo(15, 50);
        path.lineTo(0, 60);
        path.lineTo(15, 70);
        path.lineTo(15, height-20);
        path.quadTo(15, height-20, 35, height);
        path.lineTo(width-20, height);
        path.quadTo(width-20, height, width, height-20);
        path.lineTo(width, 20);
        path.quadTo(width, 20, width-20, 0);
        path.lineTo(35, 0);
        path.quadTo(35, 0, 15, 20);
        //X、Y坐标，radius半径
        canvas.drawCircle(35, 20, 20, paint);
        canvas.drawCircle(35, height-20, 20, paint);
        canvas.drawCircle(width-20, height-20, 20, paint);
        canvas.drawCircle(width-20, 20, 20, paint);
        path.close();
        canvas.drawPath(path, paint);
        super.onDraw(canvas);

    }
}
